package com.aios.model;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class Tap {
	
	private Integer tap_id;
	private String tap_name;
	private List<TapData> data_list;
	private Calendar startDate;
	private Calendar endDate;
	
	public Tap(Integer tap_id, Calendar startDate, Calendar endDate) {
		
		this.tap_id = tap_id;
		this.startDate = startDate;
		this.endDate = endDate;
		this.data_list = new ArrayList<TapData>();
		
		populate();
	}
	
	public Tap(Integer tap_id, String tap_name) {
		this.tap_id = tap_id;
		this.tap_name = tap_name;
	}

	public Integer getTap_id() {
		return tap_id;
	}

	public void setTap_id(Integer tap_id) {
		this.tap_id = tap_id;
	}

	public List<TapData> getData_list() {
		return data_list;
	}

	public void setData_list(List<TapData> data_list) {
		this.data_list = data_list;
	}
	
	public String getTap_name() {
		return tap_name;
	}

	public void setTap_name(String tap_name) {
		this.tap_name = tap_name;
	}

	private void populate() {
		Integer numberOfDays = endDate.get(Calendar.DAY_OF_YEAR) - startDate.get(Calendar.DAY_OF_YEAR);
		
		Calendar tempDate = (Calendar)startDate.clone();
		
		for(int i = 0; i <= numberOfDays; i++) {
			data_list.add(new TapData(tempDate));
			tempDate.add(Calendar.DATE, 1);
		}
	}

}
